/*
 * TitleState.cpp
 *
 *  Created on: Jan 4, 2009
 *      Author: Michael
 */

#include "TitleState.h"
#include "MainMenu.h"

TitleState *TitleState::inst = 0;

TitleState::TitleState() {}

TitleState* TitleState::Instance()
{
	if(!inst)
	{
		inst = new TitleState();
	}

	return inst;
}

//functions to handle initialization and clean up
void TitleState::Init()
{
	//load texture
	HR(D3DXCreateTextureFromFile(gd3dDevice, "Textures//TitleScreen.bmp", &m_TitleScreen));
	m_TitleScreenCenter = D3DXVECTOR3(207.5f, 102.5f, 0.0f);
}

void TitleState::CleanUp()
{
	ReleaseCOM(m_TitleScreen);
}

//functions to handle pausing and resuming a state
void TitleState::Pause()
{

}
void TitleState::Resume()
{

}

void TitleState::HandleInput(Prismatic* game)
{
	if(gDInput->keyPressed(DIK_RETURN))
	{
		//skip Title Screen intro, change states to next state, for now, main menu
		game->ChangeState(MainMenu::Instance());
	}
}

void TitleState::Render(Prismatic* game)
{
	//set flags for this render and begin
	HR(game->Sprite()->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DONOTMODIFY_RENDERSTATE));

	D3DXMATRIX texScaling;
	D3DXMatrixScaling(&texScaling, 1.0f, -1.0f, 0.0f);
	HR(gd3dDevice->SetTransform(D3DTS_TEXTURE0, &texScaling));

	//draw background, plain and simple, not doing any translations or anything
	//but if i was, they would go here as well
	HR(game->Sprite()->Draw(m_TitleScreen, 0, &m_TitleScreenCenter, 0, D3DCOLOR_XRGB(255, 255, 255)));
	HR(game->Sprite()->Flush());

	//be sure to end when done
	HR(game->Sprite()->End());
}

void TitleState::Update(Prismatic* game)
{
	//if I wasn't lazy and tired (its like 3am) i'd add a timer so that at a certain point it automatically changed to the next state
}
